﻿using Microsoft.WindowsAzure.Storage.Table;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AzureStorageLight
{
    public class StorageItem : TableEntity
    {
        public string FolderId { get { return this.PartitionKey; } }

        public string Id { get { return this.RowKey; } }

        public string Name { get; set; }

        public long Size
        {
            get { return _Size > 0 ? _Size : -1; }
            set { _Size = value; }
        }
        private long _Size;
        public DateTime Created
        {
            get
            {
                return (_Created == DateTime.MinValue) ? DateTime.UtcNow : _Created;
            }
            set { _Created = (value == DateTime.MinValue) ? DateTime.UtcNow : value; }
        }
        private DateTime _Created;
        public DateTime LastModified { get; set; }

        public string Owner { get; set; }

        public string Acl { get; set; }

        public string Type { get; set; }

        public bool IsHide { get; set; }

        public bool HasBackup { get; set; }

        internal bool IsFile { get { return Type == "File"; } }

        public StorageItem()
        {

        }
        public StorageItem(string folderId, string childId)
            : base(folderId, childId)
        {
        }
    }

}
